<extend name="Base/common"/>

<block name="style">
<link href="__CSS__/xz_stylesheet.css" rel="stylesheet">
</block>

<block name="script">
<script type="text/javascript" src="__JS__/banner.js"></script>
</block>

<block name="header">
<header class="auction">
	<div class="container">
		<div class="logo fl"><img src="__IMG__/idle/logo.png"></div>
		<div class="sub-nav fl">
			<ul>
	       		<li><a href="{:U('Xz/index')}">首页</a></li>
	       		<li><a href="{:U('Xz/add')}" class="active">发布闲置</a></li>
	       		<li><a href="{:U('User/xianzhi')}">我的闲置</a></li>
	       	</ul>
		</div>
		<div class="search">
			<form action="" method="post" autocomplete="off">
	            <input name="title" class="search-input" placeholder="搜索闲置商品">
	            <a href="javascript:;" class="search-btn fr">搜索</a>
            </form>
        </div>
	</div>
</header>
</block>

<block name="body">
<div class="container main">
	<div class="col-xs-9" style="background-color: #fff;">
		<div class="row">
			<ul class="breadcrumb" style="background-color: #f5f5f5;">
				<li>当前位置</li>
				<li><a href="#">首页</a></li>
				<li><a href="#">闲置</a></li>
				<li><a href="#">发布闲置</a></li>
			</ul>
			<div class="projects-header page-header">
				<h2>发布闲置</h2>
				<p>今天您有什么闲置宝贝发布</p>
			</div>
			<form action="{:U('saveData')}" method="post" class="form-horizontal" enctype="multipart/form-data">
				<div class="form-group">
					<label class="col-xs-2 control-label">商品标题：</label>
					<div class="col-xs-8">
						<input type="text" name="title"   placeholder="商品名称" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-2 control-label">商品分类：</label>
					<div class="col-xs-8">
						<select name="category_id" class="form-control">
							<option value="">请选择分类</option>
							<volist name="category_tree" id="cate">
			     				<optgroup label="{$cate.title}">
			     					<volist name="cate._child" id="_child">
			     						<option value="{$_child.id}" <eq name="info.category_id" value="$_child.id">selected</eq>>{$_child.title}</option>
			     					</volist>
			     				</optgroup>
			     			</volist>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-2 control-label">商品价格：</label>
					<div class="col-xs-8">
						<div class="input-group">
							<input type="text" name="price" value="" placeholder="最低价格" class="form-control">
							<div class="input-group-addon">元</div>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-2 control-label">商品库存：</label>
					<div class="col-xs-8">
						<div class="input-group">
							<input type="text" name="quantity" value="" placeholder="商品库存" class="form-control">
							<div class="input-group-addon">个</div>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-2 control-label">发货地：</label>
					<div class="col-xs-2">
						<select name="province_id" id="province" class="form-control">
							<option value="">省份</option>
							<volist name=":getProvinces()" id="province">
								<option value="{$province.province_id}">{$province.province}</option>
			     			</volist>
						</select>
						<script type="text/javascript">
			     		$(function(){
			     			$('#province').change(function(e){
			     				$('#city').html('<option value="">城市</option>');
			     				$('#area').html('<option value="">区县</option>');
			     				
			     				paramter = {format : 'json', province_id : $(this).val()};
			     				
			     				$.post('{:U('Api/Public/getCities')}', paramter, function(data){
			     					if (data.code == 1) {
			     						$.each(data.data, function(i, item){
			     							$('#city').append('<option value="' + item.city_id + '">' + item.city + '</option>');
			     						});
			     					}
			     				}, 'json');
			     			});
			     		});
			     		</script>
					</div>
					<div class="col-xs-2">
						<select name="city_id" id="city" class="form-control">
							<option value="">城市</option>
						</select>
						<script type="text/javascript">
			     		$(function(){
			     			$('#city').change(function(e){
			     				$('#area').html('');			     				
			     				paramter = {format : 'json', city_id : $(this).val()};
			     				
			     				$.post('{:U('Api/Public/getAreas')}', paramter, function(data){
			     					$('#area').append('<option value="">区县</option>');
			     					if (data.code == 1) {
			     						$.each(data.data, function(i, item){
			     							$('#area').append('<option value="' + item.area_id + '">' + item.area + '</option>');
			     						});
			     					}
			     				}, 'json');
			     			});
			     		});
			     		</script>
			     	</div>
			     	<div class="col-xs-2">
						<select name="area_id" id="area" class="form-control">
							<option value="">区县</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-2 control-label">地址：</label>
					<div class="col-xs-8">
						<input type="text" name="address"   placeholder="地址" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-2 control-label">商品描述：</label>
					<div class="col-xs-8">
						<textarea rows="6" class="form-control"></textarea>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-2 control-label">商品图片或视频：</label>
					<div class="col-xs-10 row">
						<div class="col-xs-2">
							<input type="file" id="file_img" accept="image/*" style="display: none;">
							<label for="file_img" class="btn">上传图片文件</label>
						</div>
						<div class="col-xs-2">
							<input type="file" id="file_video" accept="video/*" style="display: none;">
							<label for="file_video" class="btn">上传视频文件</label>
						</div>
						<div class="col-xs-10 files">							
							<p class="file-info">文件名称：<span class="file-name">jzb2.flv</span>
							<input type='hidden' name='pzg_movie_file[]' value='12' />
							<a class="fr" href="javascript:;"><i class="icon-remove icon-large" ></i></a></p>
						</div>
					</div>
				</div>
				<!--  -->
					<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>					
					<script type="text/javascript">
					//上传图片
				    /* 初始化上传插件 */
					$("#file_img").uploadify({
				        "height"          : 30,
				        "swf"             : "__STATIC__/uploadify/uploadify.swf",
				        "fileObjName"     : "download",
				        "buttonText"      : "上传图片",
				        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
				        "width"           : 120,
				        'removeTimeout'	  : 1,
				        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
				        "onUploadSuccess" : uploadPicture_panel,
				        'onFallback' : function() {
				            alert('未检测到兼容版本的Flash.');
				        }
				    });
					function uploadPicture_panel(file, data){
				    	var data = $.parseJSON(data);							    	
				        if(data.status){
				        	$(".files").append(
		        			"<p class='file-info'>文件名称：<span class='file-name'>"
		        			+file.name
		        			+"</span>"
		        			+"<input type='hidden' name='pzg_image_file[]' value='"+data.id+"' />"
		        			+"<a class='fr' href='javascript:;'><i class='icon-remove icon-large' ></i></a></p>"
				        	);
				        } else {
				        	updateAlert(data.info);
				        	setTimeout(function(){
				                $('#top-alert').find('button').click();
				                $(that).removeClass('disabled').prop('disabled',false);
				            },1500);
				        }
				    }
	
			    /* 初始化上传插件 */
				$("#file_video").uploadify({
			        "height"          : 30,
			        "swf"             : "__STATIC__/uploadify/uploadify.swf",
			        "fileObjName"     : "download",
			        "buttonText"      : "上传视频文件",
			        "uploader"        : "{:U('File/uploadMovie',array('session_id'=>session_id()))}",
			        "width"           : 120,
			        'removeTimeout'	  : 1,
			        'multi'			  : false,
			        'fileTypeExts'	  : '*.flv; *.avi; *.wma; *.rmvb; *.rm; *.flash; *.mp4; *.mid; *.3gp;',
			        "onUploadSuccess" : uploadMovie,
			        'onFallback' : function() {
			            alert('未检测到兼容版本的Flash.');
			        }
			    });
			
				function uploadMovie(file, data){
			    	var data = $.parseJSON(data);
			        if(data.status){
			        	$(".files").append(
			        			"<p class='file-info'>文件名称：<span class='file-name'>"
			        			+file.name
			        			+"</span>"
			        			+"<input type='hidden' name='pzg_movie_file[]' value="+data.info.id+" />"
			        			+"<a class='fr' href='javascript:;'><i class='icon-remove icon-large'></i></a></p>"
			        	);
			        	
			        } else {
			        	alert(data.info);
			        	setTimeout(function(){
			                $('#top-alert').find('button').click();
			                $(that).removeClass('disabled').prop('disabled',false);
			            },1500);
			        }
			    }	
				
				$("div").delegate(".icon-remove","click",function(){
					$(this).closest('p').remove();			
				});
				
				</script>	
				<!-- -->
				<div class="form-group">
					<label class="col-xs-2 control-label">服务保障：</label>
					<div class="col-xs-8">
						<label class="checkbox-inline"><input type="checkbox" value="1" name="security_7days">支持7天无理由退货</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-2 control-label">承诺发货时间：</label>
					<div class="col-xs-8">
						<volist name=":getStatus('security_delivery')" id="val" key="key">				    				
		    				<label class="radio-inline"><input type="radio" name="security_delivery" value="{$key-1}">{$val}</label>					
		    			</volist>
					</div>
				</div>			
				
				<div class="form-group center">
					<label class="col-xs-2 control-label"></label>
					<div class="col-xs-8">
						<a class="btn submitbtn ajax-post" href="javascript:;"
						 target-form="form-horizontal">发 布</a>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="col-xs-3 hot">
		<h5>热门商品</h5>
		<div class="form-group auto-overflow">
			<a href="#"><img src="__IMG__/qgh/img4.gif" /></a>
			<div class="fl info">
				<div class="title"><a href="#">翡翠专卖场翡翠专卖场翡翠专卖场翡翠专卖场翡翠专卖场</a></div>
				<div class="desc">
					<span class="price">￥250.00</span>
					<span class="sale fr">销量：2555</span>
				</div>
			</div>
		</div>
	</div>
</div>
</block>